As steam engine pressures increased, it was realized the exhaust steam still had useful pressure. The compound engine was invented to take advantage of this. The exhaust from a small high pressure cylinder fed into a larger low pressure cylinder to extract further work. The most famous example is probably the marine Triple Expansion Engine which greatly improved the efficiency of marine steam engines.
Compound engines were popular in marine and static applications, but their usage in railway locomotives was patchy at best. Although popular in a few locations (France comes to mind), the vast majority of 20th century steam locomotives were built with simple expansion engines.