There are several levels of compatibility in integrated circuits (ICs). Strictly speaking, "pin-compatible" refers only to two chips that have the same functions assigned to the same pins. For instance, two logic chips would have their inputs, outputs, power supply, and ground connections on the same pins.
Generally pin compatibility presumes mechanical and electrical compatibility, and the expression "pin-compatible" is often used as shorthand to refer to compatibility in all three of these senses.
ICs are mechanically compatible if they can be inserted into the same socket or soldered to the same footprint. This is generally true if (and only if) they use the same packaging standard (e.g. DIP, TO-220, TSOP, etc.).
Electrical compatibility implies that the ICs work with the same supply and signaling voltage levels. Note that (unlike mechanical compatibility) this requirement is not necessarily bidirectional (chip A can be electrically compatible with B, but not vice-versa). For instance, the HC family of chips can run on 2V to 6V supplies, while the HCT family only tolerates 4.5V to 5.5V, so an HC can be used to replace an HCT, but not vice-versa (note: this is a simplistic treatment, and HC/HCT are largely, but not fully compatible, even at the shared 5V supply).
The most widely used and recognized family of pin-compatible chips is the 74'xx series of logic ICs. The tick-mark represents the omitted type designator -- most commonly HC (high-speed CMOS), but can also be blank (original TTL), C (CMOS), LS (low-power Schottky), and many others. The "xx" represents the actual part, and ranges from 00 (quad 2-input NAND) to 40103 (8-bit synchronous binary down counter). All of the various families have remained pin-compatible over several decades of production by numerous different companies, including some versions that were not electrically compatible.