A lot of work places that have pensions you need to work a minimum of five years to be eligible for a pension even if the money started accumulating before that. If you leave at 4 years you forfeit the pension.
In the past, some companies that have closed down people lost their pensions, the money was just gone. Most pensions are kept by a third party so that can’t happen.
In the military you need to put in a minimum of 20 years to get a pension. When people leave in year 19 or get dishonorably discharged we would usually note that they lost their pension when they were so close.
In the US:
1. a pension is something an employer sets up for an employee.
2. A 401k is an account an employee pays into to defer money for after 591/2 years old. Employers sometimes help fund the account for the employee and sometimes they don’t.
3. Social Security we pay into our entire working lives as a tax to the government and it is paid out to us for the rest of our lives monthly once we start collecting it. Some people start at age 62 some older.
To piggy back on what @janbb wrote, when you leave a company after earning a pension, but you are too young to collect it, depending on the company pension policy, you might be able to take it as a lump sum and roll it into a personal IRA account. I was able to do that from one company, it was around $3k total, so not a lot of money. My husband was not able to do it at the one company he has a pension from. Instead, when he turns 65 that pension plan will start paying him monthly.