why there is 4 ground in l293d?
It's explain in the datasheet.


  A VCC1 terminal, separate from VCC2, is provided for the logic inputs to minimize device power dissipation. (pg. 2)


VCC1 is for the logic and VCC2 is for the motor supply.

The four grounds are all tied together internally and act as a heatsink for the chip. (pg. 11)