The pledge always creeped me out a bit. An oath of loyalty to the state seems like something that you do in a communist country.
The purpose was not to brainwash young kids, but to instill a set of values, something that says, "I have a responsibility to my country, my community, and, even the world."
It was to build a sense of belonging. All the history lessons taught in schools are meaningless unless the students internalize the lessons and believe they are part of history being made even now. That the history they are learning has made the opportunities everyone in the US has available and were made possible by the wisdom and sacrifices of those who lived long ago.
When you go to Sunday School, you aren't being indoctrinated into a cult -- with some notable exceptions of course. You're being taught the lessons one must know in order to appreciate what the church offers and that knowledge and experience will become the basis of whatever decision you make as an adult to either worship in that church or not.
Free wlll still exists, but there's nothing wrong with learning the Pledge. You have to know the basics before you can contemplate the meanings as they relate to you individually.