I have an animation that plays everytime when the main menu gets booted up. But when another menu gets closed to go back to the main menu the animation plays again. How do I stop the animation from playing?
You should create a default empty state in your Animation and only trigger the animation in script for the main menu. If you want to use the full animation system, that means creating an Animation Parameter and setting that in your script. If you just want to trigger the animation as a one off and not bother with a full animation state system, you can always call animator.Play and not have the animation system play it for you.
See this page for an example of how to do it.