Okay, I managed to fix it. For those having this problem, this is how I solved it:
In the animation player, add -loop at the end of the animation's name. (Example: Idle → Idle -loop). After that, go to the animation tree (state machine) and add the animations with the new name. The animation tree doesn't change them, and it treats the animations with the original name as other animation, so just remove them and add the other ones. After that, just change the name of the animations in the script, and you're done.
Hope that helps.