This Department of Defense(DoD) document is from 2010. While that's decently old, it provides for the following
It is DoD policy that support for approved travel of members and employees of
Congress shall be provided on an economical basis upon request of Congress pursuant to law, or where necessary to carry out DoD duties and responsibilities. The DoD support for travel of members and employees of Congress shall be based on:
It goes on to basically say military airlift is not for general travel needs. Section C is the relevant portion (CODEL is the acronym for Congressional delegations)
Prudent utilization of DoD transportation resources. Military airlift shall not be used for CODELs if commercial airline or aircraft (including charter) is reasonably available, i.e., able to meet the traveler’s departure and/or arrival requirements in a 24-hour period, unless highly unusual circumstances present a clear and present danger; an emergency exists; use of military airlift is more cost effective than commercial air; or other compelling operational considerations make commercial transportation unacceptable.
While they could have flown commercial to Taiwan, there had been a threat to shoot Pelosi's plane down. Thus, there was a "clear and present danger". Lloyd Austin, the current Secretary of Defense, said this about the situation with China
“We’ve seen an alarming increase in the number of unsafe aerial intercepts and confrontations at sea by [People’s Liberation Army] aircraft and vessels,” Austin said at the time. “This should worry us all.”
Austin was ostensibly trying to discourage Pelosi's trip.
There's also the upshot of having them be on an openly military aircraft. It's far less likely you have a shoot down of another country's military plane, versus, say, a civilian one (where a member of Congress did die).