I want to know if companies really care about that
The answer is really, "it depends." Some employers may not even look at your linkedin profile. If they do, it certainly won't hurt for you to have a glowing recommendation, but it's not likely to significantly change someone's opinion about you.
That said, if you're a fresh grad without much practical job experience, you may need all the help you can get when landing your first significant professional job. From a hiring manager's perspective, the best recommendations are specific recommendations. No one really cares to read a bunch of ultra-generic "oh this student was so great!" recommendations. But if you have a teacher who can write a recommendation that actually shows some specific value you're bringing to the table, that can more easily make a difference. For instance,
M.K was a pleasure to work with in my Advanced Basketweaving class - they were able to lead a team project that exceeded expectations and displayed how M.K was able to apply the material I taught to real world problems. They were also able to pick up new material and lean it independently well enough that they became a resource for other students to depend on during group study sessions.
That's the kind of recommendation you ultimately want to have on a LinkedIn profile.
You also asked,
Or they would ask for a recommendation calling by phone or e-mailing the teacher itself
The practice of calling or emailing for recommendations or reference checks is really more of a formality for HR, versus a meaningful input for the hiring manager - although that may vary for some positions. So, the person who decides whether or not to call a reference, and what to ask them, may not ultimately be the hiring manager - and it's really the hiring manager you want to impress - versus the HR person, who you want to satisfy from a perspective of being employable in a much more general sense.