You can only learn through practice, there are so many different situations that you can't just research it. You have to play and experience and discover for yourself what is good against what.
Some things to keep in mind are: Terrain, numbers, unit cost (resources as well as time), tech level of the unit, range, AOE damage, bonuses to x, (and many more)
Asking someone does x beat y, is not a good way to learn because of all these different scenarios. However if you have a replay which demonstrates the situation it's good to show it to someone and then maybe someone more experienced can help you understand what would've been a better counter in that case.
In order to learn yourself what counters what, you just have to try. Play games and lose, work out why you lost, was it because your units were countered by the enemy? If so what do you think would've been better? Next time you encounter the same situation try those units instead and see if it works.
We learn the most from losing, look through the replays of your losses to better understand what counters what and when it does (and doesnt).