Why are some countries landlocked? In the case of Bolivia its because they lost a war with Chile.
Ethiopia and Serbia granted independence to the parts of their countries that had a coast.
Some countries like uzbekistan, are so far inland that they are doubly landlocked, which means they are both landlocked and completely surrounded by other landlocked countries.
When a country is landlocked it can be difficult for them to trade, and they often have to rely on their neighbours. In Europe, the danube river lets many landlocked countries have some access to the black sea. As well, many canals exist which lets small ships travel deep inland, providing some of the benefits of having a coast.
Some countries may look landlocked, but when viewed closely you can see they have tiny coasts. You can watch this video I made which explores the weird borders in those situations:
https://youtu.be/elybAzSVSHc