That's a somewhat theoretical distinction in the case that is being discussed here, as Thai immigration doesn't give extensions that go beyond the expiration date of the applicant's passport.
But remaining in Thailand on a passport that is no longer valid, in itself, does violate Thai immigration law. For example, if your home country revokes your passport, the Thai authorities don't need any additional reason to deport you - just the fact that the passport you entered with is no longer valid suffices.