SQL will choose the index that best covers the query.
An index on A, B will cover the query for both case 1 and 3, but not for 2 (since the primary index column is A)
So to cover all three queries you need two indexes:
ALTER TABLE ... ADD INDEX (a, b); ALTER TABLE ... ADD INDEX (b)