Yes, it is possible to switch the filing basis of your trademark application under certain circumstances.
From Section 1(b) Intent to Use to Section 1(a) Use in Commerce:
This situation usually happens when the applicant wants to secure trademark rights as soon as possible and, therefore, files the application on an intent-to-use filing basis but starts using the mark in commerce shortly after.
Typically, you'd have to wait until the USPTO finishes the assessment and requests you to prove the use in commerce so you can finish the registration, but if you can prove it sooner, you can file an Amendment to Allege Use and switch your filing basis to complete the registration process quicker. The Amendment is, however, subject to an additional fee.
From Section 1(a) Use in Commerce to Section 1(b) Intent to Use:
This situation typically occurs when the applicant submits specimens of use that the USPTO deems insufficient. In that case, the applicant can usually either provide a substitute specimen or switch their filing basis to Intent to Use to buy themselves more time to provide the specimen.