This an ethics idea.
Remember that "means" have consequences that are not just the "ends" you are after.
People tend to say this when they wish to be morally tough - because they think the consequences of their actions are worth whatever hell it puts themselves or others through.
Ends DO NOT ALWAYS justify their means - it depends on the situation...
like beating up somebody who is trying to kidnap your child.