While I agree with some of the points in the other answer, some of the points (while true) are not the cause of the commitment.
The main reason for the difference of approaches is inertia.
How the support for Taiwan started
The commitment to defend Taiwan was made when Taiwan was still considered "China," while China (i.e., PRC) was still commonly called the "Red China."
Supporting the the containment of China, as a Communist country, was in line with general policy of "containment" of the Communist regimes.
The Communist regimes were defined as regimes ruled by the Communist Party (an organization which, despite national differences, considered itself an international political organization) which had an explicit stated goal of world domination.
In light of this "containment" policy, the support for Taiwan was just another support for a country which some specific Communist country targeted for a take over. This was no different from supporting South Korea against the North Korea or supporting South Vietnam against the North Vietnam.
Change from "containment" to the Reagan Doctrine
During the Soviet Union's invasion of Afghanistan, Ronald Reagan, in 1985 State Of The Union address made a refinement to the containment doctrine in a statement that became known as the "Reagan Doctrine."
we must not break faith with those who are risking their lives—on every continent, from Afghanistan to Nicaragua—to defy Soviet-supported aggression and secure rights which have been ours from birth.
This doctrine meant that the United States would not only contain the Soviet attempts at military expansion along national border lines.
It allowed arming countries/movements fighting against invasions by the Communist regimes inside the countries which were invaded. However, it meant assistance, but not direct defense, for countries willing to attempt to fight off the invading armies or Communist proxy governments.
The combination of both
Today, there are
- some countries which are under the US "nuclear umbrella" (commitment to retaliate with a nuclear strike if a nuclear weapon is used against them),
- some countries which have US defense commitments (e.g., South Korea and Taiwan, all NATO countries, etc.),
- and some countries which get heavy weapon assistance while having no commitment of direct military assistance. Israel is probably the oldest member of this list, but a number of other Middle Eastern countries are on it, too. Ukraine is probably on its to remaining on this list unless it joins NATO.
There is no universal reason why the countries in the 3rd category are not in the 2nd. It's different for each one. The relationship which resulted in their being added to that list arouse independently for each individual country.
Why Ukraine
It has come as a surprise to most people that the Communist expansionism has not gone away despite many countries rejecting Communism as their state ideology. The fact that the USSR's expansionism has been co-opted by Russia's new imperialism is not too far a leap though.
Ukraine's cause has been a surprise for a lot of people. So much so, that it is even a cause for dismay for some of them. Largely is has not yet settled in that Ukraine squarely fits the criterion stated in the Reagan Doctrine.
However, the political class clearly believes that it does (and I personally agree), so this is a case of the political class actually being ahead of the culture on seeing the change in the world.