I am taking trimagnesium citrate powder dissolved in water and I was thinking whether the citric acid is a problem to my teeth.
Magnesium citrate is not citric acid. In fact, it's not even acidic. And trimagnesium citrate is even less acidic. https://en.wikipedia.org/wiki/Magnesium_citrate
It's on the alkaline side of neutral, and in fact it's used in medicine to alkalinize patients who are acidotic. Oh, and it's also a pretty strong laxative. So your teeth will be fine. And even if it were acidic, you could just rinse your mouth with plain water afterwards and that would prevent harm.