Identifying pin numbers from PCB
Normally the square pad is pin 1.

The left picture looks like a DE9 connector - on that connector family, the pins are numbered along the row from pin 1, then the second row is numbered in the same direction, like:

   5  4  3  2  1
    9  8  7  6


For the rectangular array in your second picture, pins may be numbered either row by row, or column by column, depending on the designer's whim.

You may find pin numbers on the connector itself, or on the mating connector.