Looking for advices to stay motivated working with my master degree advisor As English is not my native language I apologize for any mistakes in my following post.

I did my Bachelor Degree in Mathematics in University "A" with advisor "a". The strees level of this University was hard, the admission tests for master degrees also are so hard , and it was so competitive. But I really enjoyed working with my thesis advisor there, it was also hard but I really learned a lot working with him, as he was a great teacher . Also he was such a supportive person.

Nowdays Im in my second semester studying a master degree in mathematics in University "B" with advisor "b" in other city. So far, I´ve enjoyed the academic system of the school (subjects, less level of stress than university a, most of teachers so far, the city, etc). The problem is that I dont feel motivated working with my advisor, he is the person who is more closed to the topics I like at university "B". Im wanted to do a topic in lets say "Categories" and he agrees as he is even  an organizer in the  categories congress here at UNiversity B.

So far, my impression so far is he doesnt really knows the subject of categories as he is more specialized in other topics in Algebra so I asked for some theses topics in the subjects he knows more but he answered weird. He sometimes talks bad  without any good arguments about the academics I worked at University A including my undergraduate advisor.

He proposed to work with me and another student in some article but I dont really feel in as sometimes he is not clearly explaining something or also answers weird or angry.

I expose him my advances in my master thesis once or twice at week and most times he is O.K, but sometimes he was weird like always correcting me how I talk every few minutes. Making jokes about the topics I expose to him which for me only show me his ignorance and lack of professionalism. There was an error in the book I study for my thesis but he responded saying that the authors are not really knowers of its field but the authors were really experienced mathematicians which again show me his bad mood and ignorance. A few minutes checking the error by my own I deduced the entire proof and I think the error was typographical.

Im doing all the research in my master theses by my own as it results he dont really knows the topic, I stay motivated by the sake of learning a topic I like.But he realy not valuates what I am doing or at least I dont feel valuated by him.

My idea is to do my PHD in another university or maybe returning to University A with my first thesis advisor. Any advices will be aprecciated in order to deal with this lack of motivation working with advisor b. Thanks
I did my bachelors and master degree in Mathematics in one of the country's top institute, but due to some reason, I am currently doing my Ph.D. in Electrical Engineering department in another country and the university is also top in the country. 

After joining Ph.D., I realize that as a Mathematics student, I do not like the research problems given to me by my supervisor. But there is one problem in which a lot of probability theory (very advanced level) is needed. I have started on my own to tackle this problem and after a year or so I have on my own progressed and published and also found a few other workable problems completely from a probability theory perspective. If I progress on these problems and publish then I am sure within the next 2–3 years I can start writing a thesis. 

I must tell you since my supervisor is not a probabilist there is zero input from his side. I hope you can do on your own too. I feel sometimes the same way as you. But I really like the area I am in now. So at the end of the day, you have to find a problem and solve it, there will be rarely you and your supervisor both thinking and solving the problem together in my opinion.