Why are my cells counted as different cell blocks?

The algorithm that tries to group up cells can't handle the particular shape you are using there. Since it can't find a group of cells to make a cell block, it will make the larger structure it can find a cell block. I think in this case it has to do with the family cells not being recognised as cells for a cell block.

For the middle cell block, add a large jail door and a small jail door to block off the common room. They can be locked open, but now the cells are grouped together.

Middle cell block

For the lower cell block, block off the lower part. Alternatively, dezone the lower part.

Lower cell block

Dezoned lower block

In general, try to block off a group of cells with jail doors, and minimise the number of other rooms in that block.