It works like this:
Warm and moist air rises because warmer air is less dense and therefore, lighter. As it does, it cools down by the adiabatic effect of a lesser pressure aloft. When it reaches what is called the dew point temperature, it is entirely saturate with moisture and must start condensing in small droplets. That is the base of the cloud that, indeed, is flat.
Each parcel of warm air keeps rising until it reaches an altitude with air of equal temperature. Each parcel is then a top of the cauliflower like cloud, the cumulus cloud.
But not all clouds are formed that way. Cumulus clouds appear when there is a convection, i.e. warm air that rises. But sometimes, the air is warmer above than under. This is called an inversion and between those layers, stratus clouds and even fog, forms. Those are not flat bottomed. High above, the cirrus, clouds formed by ice crystals of ancients clouds, are not flat bottomed either. They look more like thin hair taken away by the upper winds.
Now you know that the flat bottom of those clouds is the altitude at which the temperature is that of dew point. A rule of thumb is that the temperature sinks with roughly 2C (3F) per 1,000 ft of altitude. If you then read a weather report that says that e.g. the temperature is 20C and dew point is 16C then you know that the base of the clouds is at about 2,000 ft because it will take that to see the 20C to go down to 16C.
Just an extra note: Actually the base of a cumulus is slightly concave. That is because the air rises sligthly faster at the center than the edges. You can notice it from the ground but, as a pilot of a very light aircraft, I notice it sometimes. Glider pilots use that rising air to gain altitude and often circle under such cumulus clouds. Sometimes they are surprised to reach the "inside" of the concave and loose vision of the horizon, which is not good. A rapid descent is asked for, then. Not easy, though, because the air can rise fast under a cumulus. And that's why glider pilots often wear a parachute.