Capitalism is a layered concept that is inextricable from the fabric of American society.
Case in point: This short video from NPR that talks about how the pledge of allegiance really became so widespread as to be recited in schools.
In a nutshell: Just like the national anthem being played at NFL games, it was just a marketing ploy. In an effort to present a more united United States post-Civil War, the publishers of the Youth’s Companion magazine gave free American flags to the students who sold more subscriptions. A copywriter created the pledge as part of that, and it took off and was in just about all schools by the time World War I started and people were at a nationalist peak.