The drivetrain wears as a unit, but the smaller sprockets on the rear cassette tend to wear more because the wear is concentrated on fewer teeth. Putting a new chain on a worn cassette can result in the new chain failing to engage securely with those smaller sprockets, so standard practice is to replace both chain and cassette at the same time. The large chainrings on the crank can last a very long time compared to chains and sprockets, but if you do a lot of riding in abrasive/corrosive conditions and neglect routine maintenance you may eventually need to replace them as well.