1. The Institute doesn't want to risk any of their people on the surface because, God bless them, they're a bunch of pampered nerds. Hence, they made robots almost identical to humans in every way as infiltrators. They also made the Gen 1s who are dispoable kill bots and the Gen 2s which are the same but smarter/stronger.
2. The Railroad is made of people who married, befriended, or ARE Synths. It's easy to dismiss a machine like Codsworth as unworthy of protection, awesome as he may be, less so when the Synth is a hot French chick. Also, the Railroad it should be noted includes many people who aren't just Pro-Synth but anti-Institute. While some people become violently anti-Synth when loved ones are kidnapped, justifiably so, others decide the best people to recruit to destroy the Institute are those who are depended on to keep it running.