Typically though gas is used in the U.S. for more than cooking (stoves): heating water. More and more people are shifting to on-demand tankless heaters but even with those the perception is gas is better than electric.
Is this the case for new construction too? Why aren't heat pumps used these days?
They lose efficiency in very cold conditions (https://en.wikipedia.org/wiki/Air_source_heat_pumps#In_cold_...). Albany, New York (https://www.weather.gov/aly/SpecialDataALB) has an official all-time record low of -28F (-33C), which is well below the point where air-source heat pumps have any meaningful efficiency advantage over even resistive heating.
Heat-pump solutions that use the ground as their heatsink are much more expensive because of the excavation required.
What we do have in Sweden is cheap renewable electricity so choosing heat pump over oil/gas doesn’t just mean electric it means renewable over fossil too.
Heat pumps are likely not used in New York state because most of them cannot warm the house sufficiently during the coldest winter temperatures (0F or less).
That's what's happening in some city centers in Europe as fewer and fewer residents use gas, those that do need to share the maintenance costs for the gas network, which makes it more and more expensive to keep using it so there is a spiral of people leaving. In stockholm it's now north of $200/year for a studio apartment even before buying any gas. You get quite a bit of cooking electricity for $200!