A key only fits into a lock if it matches the zig-zag hole pattern called a Keyway.
Each manufacturer makes their own unique keyways. This is to ensure they differ from all others brands. That is why a Schlage key will not fit into a Yale lock. The zig zag patterns are different.
Often times the name of the keyway is stamped on the key bow (EF in example).
When keys are cut they create peaks and valleys. Counting the valleys will denote the number of pins in the matching cylinder. Residential locks have 5 pins while commercial locks have 6. Large institutions such as universities sometimes use 7-pin cylinders.