Так и надо - все говорят,
Так и надо - сам виноват - так и надо in these 2 cases is a set phrase it means 'you deserved it, you are to blame yourself'

Так и надо идти, не страшась пути - the words так и надо идти are used as separate words here (not a set phrase) in their literal meanings, i.e. that is the way to go, and don't be afraid of that way....

does that help?