So, it's just a "lack of practice" which doesn't mean you're a freshman at coding.
Our brain works in "rooms" or in "departments". Have you ever make the experience of wanting to do something and therefore go to another room. Arriving there, you've forgotten what you actually wanted? That's experienced by, I would assume, all of us. You just won't remember, what you wanted to do from one second to other .. BUT, if you go back to the room you had the initial thought in and in which you walked out from, then, suddenly it strike's you and you suddenly remember what you wanted to do. Just because our brain is working "in rooms". In each room we have our concepts (compare TV vs kitchen).
So obviously you have "learned two languages in the same brain room". What you now need is to separate this both rooms again. It just can be done by explicitly provoking that situation. For example, take a python code and translate it purely to JS while live coding. Or code different languages in different workspaces or even locations. You need to introduce a brain room separator somehow. Then it's just a thing of brain & thinking in rooms.
The same problem is faced by language translators, people speaking more than one language. All of them exercise and train to use different 'rooms' while learning to translate. Another example is the live translation of spoken to sign language. You have to explicitly train how to move your hands by hearing certain words. And even more, you have to explicitly train how to hear, think and make movements of hands, while/with the information coming in linearly/steadily with future context one might need to understand coming, well, in the future.
So it's just practice. You need to provoke such situations so your brain get used to fast context switching.
(My experience with that, although not coding:
I speak Russian as mother language. German is my second mother language. English is okay, I think. Learned 3 years French language. Spoke a little French on daily basis. Then started to learn Chinese. One French guy asked me if i can understand what he's talking about, I said yes of course and gave him instructions how to go to the place he wanted - in Chinese. I didn't even notice it. That guy didn't understand a word, while I'm being sure to communicate with that guy the same language.
Later, i went to China. Spoke fluently Chinese. But I needed like 10 minutes to switch from Chinese to English, when I wanted to talk to foreigners in English. Words just didn't come out. After some switching time of like 10 minutes, English has been coming out fluently, more or less. I decided not to speak it anymore that time.
After that, my girlfriend wanted to exercise English. So we had to speak Chinese mixed with English. Mix up the grammer. Mix up sentence by sentence. Which, actually needed fast switching capabilities that she nor I did have. After 1-2 months of daily talking on the phone - my and her brain got used to it. I noticed, I just could switch and use both languages mixed simultaneously. Even the grammar of one with the vocabulary of the other was possible without a problem. I tried to use other language combinations and it was possible too.. now I can switch my 4+1 natural languages JIT)
So there's not much you can do, except provoking such situations, doing translation and ... Actually ... It's training.