This is technically true, however, in many cases the government has already waived immunity through past legislation, or a court has already found that immunity doesn't apply to particular cases due to for example constitutional reasons. Crucially, it's not like everyone who sues the government has to beg a judge every time before filing the suit.
See: https://en.wikipedia.org/wiki/Sovereign_immunity_in_the_Unit....