In more detail
Routers read each packet's destination address and send it on to the next hop. They keep a routing table of network prefixes and next hops; for each packet they pick the most specific matching route (the longest prefix match) and fall back to the default route 0.0.0.0/0 when nothing else matches. Each router also lowers the packet's TTL by one. Internet routers exchange routes with protocols such as BGP; a home router normally knows only the local network and one default route to the provider.
Why it matters
A home router also acts as the default gateway, hands out addresses with DHCP, performs NAT and usually includes Wi-Fi and a basic Firewall, so "the router" can be at fault in many different ways. traceroute (or tracert on Windows) lists the routers a packet passes through and shows where a path breaks.
Example
A routing table holds 0.0.0.0/0, 198.51.100.0/24 and 198.51.100.128/25. A packet for 198.51.100.200 matches all three, and the /25 wins because it is the most specific. A packet for 198.51.100.20 matches only the /24 and the default route, so it follows the /24. Anything else takes the default route.