Sure, those are a factor but it isn’t like the food themselves have the same kind of chemicals you’d find in things like drugs, cigarettes and alcohol. Those are two huge differences.
You can completely stop those things. You can't stop eating.
There's definitely an element of personal responsibility however it's not always as simple as that. Ultra-processed foods are cheap, have long shelf lives and can be quick and easy to prepare. I don't know if you've ever tried to go on a diet to avoid UPF as much as possible, but it's way more expensive, takes a lot more effort to cook everything from scratch, and generally doesn't last long at home. For a lot people, they don't have the luxury or time to manage such a diet.
Some people are more susceptible to addiction than others. For some, having a pack of biscuits or doughnuts in the house would be torture and would have to eat the lot if they're there, where as for others they wouldn't even think about it at all and probably forget they exist. Of course, people need to take that responsibility and not buy them, but you can say that about any addict.