There are two ways to organise social security. One scheme is known as fully-funded social security. The alternative is called pay-as-you-go.
Fully funded schemes
Under a fully-funded scheme, the government collects regular payment from each member. These payments are invested until the member needs to claim (e.g. their pension), at which point the member receives payments from the invested money and the returns that it has generated. This corresponds to the situation you describe where your social security payments are sat in an investment somewhere waiting to go back to you.
Pay as you go schemes
This may be disturbing reading, so brace yourself!
Countries such as the UK and the USA do not use a fully-funded scheme. Instead, a significant portion of their social security provision operates on the basis of a so-called pay-as-you-go scheme in which the money paid by today's workers (e.g. you) is not invested at all. Instead, it is immediately spent on making social security payments to people who are currently retired. The hope is that today's workers, when they eventually retire, will likewise have their pensions paid from the social security contributions of their children (who will by then be working). And so the chain continues, each generation handing money directly to the last with little provision for self-sufficiency.
The obvious problem with this is that the generation of 'boomers' now retiring is unusually large and had unusually few children. Moreover, that generation enjoys unprecedented levels of longevity, meaning that they are likely to claim far more out of the system than they paid in. All this means that current workers face a large burden paying the social security claims of the much larger generation that preceded them.
However, we are kind of stuck. If we want to switch to a fully-funded system then somebody has to get a very bad deal. Option 1: current employees have to pay twice (for their own fully-funded retirement and for the pay as you go claims of their parents). Option 2: current workers pay only for their fully-funded retirement and current retirees (who already paid for their parents' pensions) do not receive any pension at all. Neither alternative is very politically tractable.