This is standard functionality and something that you want .... or maybe not in your case
The text is changing to white because Tableau detects that there's not enough contrast between the background (a dark colour) and the text (also a dark colour) so changes the text to white. If the cell size is too small, it can't do this calculation so the text is black.
Here are some small cells:
If I make the cells about 2 pixels taller I get this:
The only thing I changed in the sheet was the cell height.
If you want to force the text to be always black, just change the text colour:
Then click on Font and choose the colour and it will be fixed on that colour.