The book's index — same idea
An index is the database's back-of-the-book index. Looking up "transactions" in the index of a 600-page book takes a glance; reading every page until you find the word takes hours. PostgreSQL indexes work the same way: they're a separate sorted structure that points back to the table rows, turning O(N) scans into O(log N) lookups.
The trade-off
Indexes are not free. Every INSERT, UPDATE, or DELETE has to update every index on the table. Indexes also take disk space — sometimes more than the table itself. The right number of indexes is the smallest set that supports the queries that actually matter. Adding an index "just in case" is exactly how schemas decay.
What gets indexed automatically
PostgreSQL creates an index automatically for: PRIMARY KEY, UNIQUE constraint. Foreign keys do NOT get an index automatically — this is one of the most common performance pitfalls. Always index your foreign keys.