Could an American explain this about voting?

I've just read an article on BBC news about the elections you're now having. It contains the following paragraph.

"Data from states that require voters to register a political affiliation indicates an increase is votes cast by Democrats, while Republican early voting numbers remain generally similar to 2022."

Now this is really confusing for us in the UK because here who you vote for is considered a private matter. You're welcome to tell people who you're voting for but that's your choice.

So if I'm reading this right, you don't have any anonymity in America when it comes to who you support, you have to register an affiliation. Isn't that dangerous?
Updates
1 d
Thanks to everyone who explained. Makes me glad I live in free country where the government doesn't track me like thar.
Updates
22 h
Can I look up who people are registered to so I know who not to employ?
Could an American explain this about voting?
Post Opinion