In addition to the above answer we could also have some fine-drawn distinctions:Congratulations on your baby.
(I am a well-wisher here, I wish well to you and your baby. - on the context of a happy event.)Congratulations on your marriage.
(same here.)Congratulations for saving the farm from foreclosure!
(I mean somehow "well done" for some feat you have done - I am praising you/your feat).Congratulations to
(would be to either - you wish well - or for something that somebody has done and you are praising it/him/her/they.)The townspeople offered congratulations to the utility company for the swift restoration of power.
I hope this helps. BTW, congrats for your inquisitive learner mind/for being such an inquisitive learners. https://www.collinsdictionary.com/dictionary/english/congratulations