For graduate admissions, is it better to attend a well-known undergrad program with advanced coursework or one where I can write a bachelors' thesis?
If I were you, I would try to move to B based on the assumption that B is better than A and A is probably less recognizable in the US than B schools.

You are right that research potential is an important factor the admission committees of top schools will pay attention to. However, bachelor thesis is not the only way to show that you can do research. You can do research papers with professors' supervision at school B if you want.

I suggest B since you can learn a lot more in B than in A. Building the foundations during undergrad stage is more important than doing research prematurely. 

When you apply graduate schools, you need to provide GPA, GRE/TOEFL scores, recommendation letters and any evidence that you can do research.  One of the first things the admission committee will look at is your transcript to determine if you are competent in math. If you stay in A, all you can show is basic to intermediate level math courses. Given that all other conditions will be equal, i.e. you'll get the same GRE/TOEFL scores, about the same recommendation letters (I am not too sure about that), the only thing you can use to beat other applicants is your very good quality bachelor thesis. But, how can you write a very good thesis without having solid math knowledge?

Thus, I am suggesting B. I do understand how tough is the admission exam in that part of the world. It's bloody. Good luck!