How do they behave? Are they used to being in a carrier?
If they are nice and likely not turn out to be a nuisance, definitely take them along in the cabin all the way.
Flying United, you will only have the option of either carrying them on or send them as cargo - for the general public, United does not transport animals as checked baggage anymore. They did away with that after the merger, adopting COs cargo-based "PetSafe" program instead.
United also has a plenty of restrictions for longhaul travel with in-cabin pets - I'd suggest booking the transatlantic segment on LH if you plan to carry them on in the cabin, where there are basically no restrictions apart from size and weight of the carrier.
Animals are never interlined between airlines, and you'd have to claim them from the cargo terminal at the transfer point from UA to LH if you were using PetSafe for the United flights. Sending them to Baku all the way with PetSafe wil turn out very costly.
You say you have four flights - I presume two of those will be US domestic segments, then the TATL to Frankfurt, then connecting to GYE on LH.
While all UA hubs (IAH, EWR, SFO) offer pet relief areas, none has them airside so you'd need to get outside and reclear security for potty breaks. Keep that in mind while booking connections.
The same in Frankfurt - you will need to pass immigration/customs and exit the terminal if you want to give them a bathroom break walk. This means they need to adhere to all EU animal health regulations (rabies shot documentation, EU-style microchip, paperwork stamped by accredited USDA vet - read
this post for details and links) or customs might not let you pass with them. However, I never have been asked for anything when arriving in FRA with my dog and just walked through customs on all of our maybe two dozen trips through there.