divs fall outside div borders when more than 2 are present
After each commentcontent there is one closing </div>
too much.
So after the first commentcontent the parent comment div is closed (too soon). After the second commentcontent the parent modal div gets closed (too soon). After the third ...
So that probably means that your php script generates one </div>
too much for each commentcontent.
BTW commentcontent should probably be a class instead of an id.