Let's say you interviewed at a company that you'd really like to work for but didn't get the job. From what I understand, it's a good idea to get in touch every now and then afterwards, to show that you're still interested in them..
Have you ever heard the phrase:
You don't get a second chance to make a first impression.?
If you were passed over for employment at a company, then the hiring manager likely had a good reason. This judgment will not change because you will not have a second opportunity to convince the hiring manager otherwise.
OTOH - If you narrowly missed employment, but still made a great first impression, then the company and/or hiring manager will remember you; and they will contact you if an opportunity becomes available.
Why will they remember you? Because
Good help is hard to find. Moreover, if you interfaced with the company by way of a corporate recruiter, then the recruiter will remember you because performance and/or financial incentives motivate them to place candidates into jobs.
Keep in mind - One hiring manager's decision is not a popular referendum on your abilities. It just means that you weren't a good fit for this job at this point in time.
Emphasis: After a few years, you may improve your skills and apply for a different job with the same company or even the same job with the same company but with a different hiring manager.
For now though, it's probably not worth your while to ping the same hiring manager or same recruiter about other opportunities with the company. People are busy, and it's very presumptuous for you to expect them to "keep you in mind" when they already rejected you once. It's also enormously difficult to change someone's mind.