Sometimes I accidentally make duas in my mind which I do not want. If I want something, my mind says something opposite and I start smacking my head because I do not want that dua in my mind to be accepted. What do I do? It happens all the time whenever I try to make dua my mind just says something else and it makes me worry.
Islam is all about "niyatt" (intention). If you do a bad deed accidentally, without the intention of it, you are not to be considered punishable. Similarly, if you make a prayer accidentally, and do not mean it truly from your heart, it is mostly not going to affect anything.
Just try to focus on what you really are asking for when making a dua, and imagine that you are standing right in front of Allah Ta'alah. That may help keep your attention from diverting, stopping from opposite thoughts and such. Allah 'aelam
A dua is not something that happens in the mind only. To have a valid dua you have to speak the words as well so if you have something in your mind that you don't think is correct and you speak what you do want to say instead then you're fine and that will be your actual dua so long as you are convinced of what you are asking, even if your mind is offering conflicting thoughts.