The following covers the pinout for the various key pad products.
Each keypad is a combination of row and column circuits. The buttons themselves are simple switch like closures in these circuits. Here's an example of a basic 4x4 keypad arrangement.
There is 1 pin for each column and 1 pin for each row. So for the 4x4 keypad, there are 4 + 4 = 8 total pins. For the 3x4 keypad, there are 3 + 4 = 7 pins. Etc. Each of these needs to be connected to a separate digital pin on the microcontroller.
In the diagram above, the pins 1-4 correspond to the columns while pins 5-8 correspond to rows. Determining if a particular button is pressed is done by programmatically changing the digital pins between input and output and reading pin state. Doing this across all possible pin combinations is referred to as a scan. All of that work is typically taken care of for you in a library.