When you say "mostly optional" I assume you mean working out will drastically reduce the rate of muscle loss. Is that what you mean or are there other intervention?
You will still get less strong with age even if you do this but vast bulk of sarcopenia is just atrophy. Also worth noting that preservation is easier than gaining. Meaning if you get strong you can keep most of it with less effort than it took to acquire it.
The wikipedia has a good overview of factors and prevention https://en.wikipedia.org/wiki/Sarcopenia