It’s not random.
The red appears whenever you close or switch away from any app that uses the microphone to let you know that the app is running in the background. Then it goes away once the app has closed.
Sometimes apps take a second or two to fully close when you switch away from them, which is why they may appear briefly after you close them, then disappear after.
You can change which apps have access to your microphone in Settings > Privacy > Microphone. You’re in full control.