There are two basic problems in this question. One is with respect to future episodes, and the second is whether to fix the current episode.
To me, the key to for future workflow lies in not extruding faces, because extruding the face results in the creation of the four faces on each side of each extruded face which descends to the mesh base, and partially duplicates the similar face on the adjoining face. This creates your problem. I submit that the key here is extruding vertices, and making a face after all four of the constituent vertices have been extruded.
Starting with one corner, at that corner you will have one (if the plane that would be extruded happens to have vertices which have the same co-ordinates as the base plane) or two vertices with the same x,y co-ordinates. So you extrude (x,y,z') from (x,y,z) so that z' has the appropriate height value.
Next you move to an adjacent vertex in the base plane. (x',y,z) [or x, y', z]. At this location, there may be zero (if both adjoining planes are at the same z value as the base), one (if both adjoining planes have the same value, but different from the base), or two additional co-ordinate values along the z axis, and if there are two additional values, either may be greater than the other. So extrude from the vertex (x',y, z) along the z axis to reach the lower location with the lower z value of the other two, which will be (x', y, z'), and then extrude again to the other higher z value, (x', y, z''). One of these two extruded z values will be the same height as the z value of the previous base vertex, so create the edge between those two vertices, and create a face between the newly created edge and the edge below it. Repeat this process for each vertex on the edge, until the opposite corner, where there will be only zero or one additional vertices.
Moving to the next row of vertices, (x, y', z), repeat the steps outlined in the previous paragraph for the first vertex in the row, remembering that in this case the first vertex in the row is equivalent to the vertices other than the two corner vertices in the first row. Now when moving to the adjacent vertex along the x axis, (x' y' z), there are four faces which will each have a vertex which maps to the same (x' y') co-ordinates, so there will be as many as four separate vertices to be extruded along the z axis, although it is possible of two or more of the faces happen to be at the same height, there will be fewer than four extruded vertices.
Determine the height for the four extruded vertices, (x', y', z'), (x', y', z''), (x', y', z'''), and (x', y', z''''), sort these four z values, and extrude from the base mesh vertex to the lowest z value. If this z value matches the z value of one of the adjacent vertices already extruded, make the edge. Extrude from the lowest extruded vertex to the other three in order of z value, drawing edges as needed. When an edge is drawn, check to see if that edge completes a face, and make the face as well. Repeat the process outlined in the above paragraph and this one for each successive row of vertices.
The last row of vertices will be like the first row.
I think this will provide you with what your are looking for, and have the beneficial side effect of providing the possibility of providing a very interesting animation to look at, as the process proceeds across the image. Unfortunately, while my analytical skills are up to devising the method, my programming skills are not up to providing the code.
As far as a method to correct your current mesh, this, too, is based upon vertices and edges instead of faces. Again, processing occurs along the vertices of the base mesh. On the perimeter sides of the base mesh, delete all edges where both the ends of the edge lie on the z axis, then construct edges between each two adjacent vertices (adjacent means that given two vertices with co-ordinates (x, y, z) and (x, y, z') there is not vertex with a value between the value of z and the value of z'). The same process is repeated for vertices on the interior of the base mesh (that is vertices which are part of four edges), except that the lowest edge, that the edge between the base mesh and the vertex with the next highest value along the z axis is NOT drawn.