not all, but many papers (that are accepted and published) are based on ideas that can be patented as well
This is a misconception. Even in engineering, only a small minority of papers contain ideas worth patenting. The further you get from engineering, the smaller this fraction gets.
So, why is that there is no system in which a person can apply for a publishing a paper and also getting the idea patented at the same time?
You can indeed do both things in parallel, but not via the same process. Publishing a paper is an academic process, whereas filing a patent application is a legal process, and the two things just don't overlap very much.
It's kind of like asking why you can't write your dissertation and apply for jobs via the same process. You can certainly work on both at the same time, and there is a relationship between them, but fundamentally they aren't the same thing.
Is it possible that I publish a paper, do not get it patented and during that time someone else patents my work in his name?
No, it's not possible. Well, technically someone could try, but they would be wasting their time, since your paper would serve as "prior art" that would invalidate the patent.
Or someone else picks up my theory, develops it further and gets a patent?
That could happen, whether or not you file for a patent. They would own the intellectual property rights to the extension of your work, but not to your work itself.