Your salat is not batil since is thinking. You don’t have to repeat your salat.
However, it’s important to reduce the thinking:
1. Prepare for salat in advance. Meaning, make wudhu some minutes before the actual salat time. Do some optional payers before or do some long prostration before the actual obligatory salat.
2. Try to spend time to understand whatever you recite in salat.