rectangle() is a 2D object only, and is not certain to show up at all unless the viewpoint is from directly above or directly below.
There are other MATLAB handle-graphic objects that are 2D only as well, such as image objects; the same difficulty applies to them.
line and lineseries objects such as are produced by plot() can have this same difficulty if only X and Y was specified, but fortunately these line objects can be made 3D by set()'ing their ZData property to be non-empty.
If you need your shape to be visible at other angles, you need to draw it as a patch() or surface(). (For images, usually the easiest approach is to texture-map them on to a patch or surface object.)
