Is there a formal proof? or is it by definition?
There are proofs, but what approach best suites your setup depends on how you define volume in the first place.
One possible approach is to define volume as an integral over areas. Conceptually, you split your shape into slices of the same thickness, compute the area of each slice, multiply each by its thickness and add them up. In the limit, the slices will become infinitesimally thin, but you'll get an finfinite number of them, and end up with an integral instead of a sum (don't let the formula distract you if you don't feel at home with this kind of notation):
$$V = \int_0^h A(z)\,\mathrm dz$$
If you consider $z=0$ to be the plane containing the base, then you can think of other $z$ values as different distances from that base plane, resulting in parallel planes intersecting your body. One thing is readily apparent from this definition is the following: all that matters is the area of the intersection of your body with such a plane. It does not matter where that area is located, or how it is shaped. This is also known as Cavalieri's principle, and is sometimes used to derive a formula for the volume of the sphere.
Applied to your case, every intersection with a plane parallel to the base results in a parallelogram shape congurent to the base itself. So all slices have the same area $A$, and it doesn't matter whether they are offset against one another, or placed directly one above the other like in a prism. You can either use this to get back to a cuboid of same volume (via a prism as intermediate shape), or plug the constant area into the formula above:
$$ V = \int_0^hA\,\mathrm dz = A\,\int_0^h\mathrm dz = A\,h $$