Its a combo of diet, exercise and rest. Hitting the muscle groups at least 1 time per week is good, best is 2 times. But you need to rest well for them to recover.
If you eat very little to stay lean, unless you are genetically gifted going to the gym once per week, will not be good, because there is not a stimulus for the body to retain the muscle, the body wants to retain fat, not muscles, therefore eating that low will make you lose a ton of muscle.
You want to stay lean: hit the gym hard 3 x week and eat in a caloric deficit or at maintenance
You wanna build muscle: hit the gym hard 3 x week and eat in a caloric surplus.