The ruling is quite clear: the Ghusl of Janabah is wajib in certain circumstances. When the circumstance arises, Ghusl is deemed wajib.
Your question is unclear: how can Ghusl be performed when you were not sure that it was Wajib?
If you follow the rule of thumb above, insha'Allah life will become easier. Strive to stop Satan from creating doubts in your mind.