Like any other human cognitive feature, animals can do math, but in a very limited way. See https://www.bbc.com/future/article/20200907-the-remarkable-ways-animals-understand-numbers
If you read Harari (if you haven't read his first book, you should, it is really great), he explains very nicely that the main differences between us and other animals are the ones that help us to collaborate and have collective goals and planning: language, creativity, shared ideas and dreams... We are much, much better.
Math and logic are a form of language, so we are naturally much, much better than animals at it.