The control water spell's Flood option lets you:
cause the water level of all standing water in the area to rise by as much as 20 feet.
Does this create new water, or simply levitate the water already present? Can it be used to target an artificial container?
If yes, what happens if you raise the water level above the apex of its container (say a river above its river bed or a barrel of water beyond its capacity), what happens to the excess water? The spell states:
If the area includes a shore, the flooding water spills over onto dry land.
Does the edge of an artificial container count as a "shore"? If not, what happens to a filled container when the water level rises 20 feet? If it does count as a shore, does the water fill the external space 20 feet above the apex, or is the expected volume of water conserved (as if the apex had been 20 feet higher)?
Essentially, what happens if the container for the water is insufficient to contain the new volume (or levitated volume)?
A barrel of water is an invalid target for Control Water
Control Water states that you must target freestanding water:
Freestanding water is natural water in lakes, rivers, swamps. Read this answer for more information. While a manmade pond or dam might create questionable situations for your DM to resolve, a barrel of water is clearly not a valid target.
As such when Control Water states:
It is referring to the land surrounding the lake, river, swamp, etc. That is why the wording seems so confusing when you target a barrel, you are using it in a way that is not allowed.
If you target a valid body of water the spell is explicit about what happens, the water level rises and the flooding water spills over onto dry land.
As for your other query:
You can use the Polymorph spell to transmute a human into an elephant. Even though an elephant has more mass than a human, the spell magically performs the task. There is no real explanation as to how this works, it's magic.
It's the same with Control Water. Nothing is ever created. The water is transmuted from the existing water. The water does not levitate, only the water level rises.