Expected: Command below would set my health to half heart, and 20 would set my health to 10 hearts
/attribute @p minecraft:generic.max_health base set 1
/attribute @p minecraft:generic.max_health base set 2
/attribute @p minecraft:generic.max_health base set 3
/attribute @p minecraft:generic.max_health base set 4
Observed:
1 and 2 both set it to a full heart, 3 and 4 both set it to 2 full hearts
Linked issues
duplicates 1
Attachments
Comments 3

The bug is actually different: Your current health does not get reduced to the maximum health at all. Changing the maximum health from e.g. 20 to 1 just hides the last 9 hearts, so you don't see that they're still full, but you see the last heart being full. Closing and reopening the world fixes this for some reason.

Resolving as duplicate of MC-180001 since that describes the underlying bug better.
Seems to be a sync issue – max_health sets correctly, but your current health is wrong. If you take a half heart of damage you don't regenerate the "extra".