I am in the final year of my master in mechatronics engineering in Germany, and I want to work as a researcher or a professor in a university since i believe a professor/researcher has more freedom than an engineer within a company.
I don't have any experiences in the academic field, so I suppose I have to get some somehow.
What are good option to pursue as a career path in Germany to get a professor position at a university? Do I need to get a PhD? Is it better to become assistant professor on that path, or a research engineer?
Your chances of becoming an academic researcher without a PhD are negligible. If you want to take this path, that is the first step. However, as far as I know long-term job prospects in German engineering faculties are not better than in other parts of academia (and maybe worse). Furthermore, many departments prefer if there PhD students have experience in the industry. You can certainly apply without such an experience, but competition is strong.
My advice is: Get an entry level job in the industry. If after two or three years you would still like to do research, apply for PhD positions at universities and research institutes. When you have your PhD, you can look for research positions in the industry or decide to stay in academia and start on the long hard road to a permanent position. If you then still want to become a professor (why would you? Usually you'd be a glorified manager and hardly do any research yourself.), you can do a habilitation. If you are extremely lucky (in addition to being very good, successful and a great networker), you'd might get a position as a professor someday. Chances for that are slim.