Religious practice precedes religious belief. The first generation to perform religious practices don't do it for "religious" reasons. They don't really "believe" that a flag is a person and that it fundamentally deserves to be treated like one, they just choose to act that way. But when the following generations are raised seeing adults consistently treat a flag like a person, they DO take on religious beliefs towards the flag. And it quickly gets creepy and scary.
American flag worship is a little creepy, honestly.
save