The key point here is exactly the idea of the constant speed (rectangle).
Let it be an arbitrarily changing velocity. Since at every instant in time the speed changes, it will be almost impossible to calculate the displacement. At this point, the best you can do is to give away of the actual value and accept an approximated value. To do so, at certain moments in time, let’s say at every 2 seconds you pick the corresponding value of speed and calculate the displacement as if speed was constant. At this point, what you will end up with are small rectangles representing small amounts of the displacement. The total approximated displacement will be the sum of the small displacements.
To better show this, let’s use the triangle (constant acceleration) of your example. In the first figure the plot of displacement vs time for a particle moving with a constant acceleration of $\rm a=1m/s^2$ is shown. After $\rm t=10 s$ it forms the triangle with sides of 10 by 10 units, whose area is $\rm \frac{1}{2}×10×10$ represented in red.

After Appling the 2 by 2 seconds sampling process you get the green rectangles of the second image. Has you can see, the total approximated displacement is an underestimation of the actual displacement, since, for example, in $\rm t=3s$ you still consider that velocity equals $\rm 2m/s$ but in reality it is higher ($\rm 3m/s$).

However, if you make thinner and thinner rectangles and then sum them up, your approximation will get closer and closer to the actual value. For example, if one uses a 1 second sampling, the error pointed before for for $\rm t=3s$ will disappear, but not the error for $\rm t=2.5s$ or $\rm t=3.5s$.

In the end, if you use instant sampling (infinitely thin rectangles) and then sum the resulting infinite number of rectangles your approximated value will match the actual value and the green area (which we shown to be equal to the approximated displacement) will become equal to the red area, i.e, the actual value for the displacement equals the area under the speed vs time curve.
For further reading search for the following keywords.
Geometric representation of integration.
Integration as summation.
PS: This doesn’t mean displacement is a sort of “area”. It is just the result of representing graphs or plots of functions in a “piece of paper”. This means that when one represents any quantity as a graph the magnitude of such a quantity will be represented as a length, therefore, any quantity that results from the multiplication of the axes of such a graph will be represented as an area. For example, work will be equal to the area under the force vs displacement curve, and electric charge will be equal to the area under the current intensity vs time curve.