You don't actually pay these taxes until next year, so it's perfectly legal for them to change the rates. The Congress may not choose to make the taxes retroactive. As you say, it makes people cranky to have their decisions changed out from under them. But they didn't become criminals retroactively; the tax isn't due yet.
So yes, it's allowable. Whether it's desirable is up to Congress. (Presidents don't set taxes. They just make budget requests.)
If you find this so upsetting, I'm afraid you're in for a rough ride. The government has the power to change lots of stuff after you've made investments. They changed the rules on mortgage tax deductions in 2017. Businesses buy land and then discover that the government won't build a road there. And so on. Hell, the weather throws off your plans.
You have a lot less control over your life than you seem to imagine, but it's not apocalyptic. People control lots of stuff, and smart ones plan surpluses for unexpected eventualities. That's easier when you're the sort of person who has capital gains taxes to pay, which is why they raise this tax rather than some other tax.