This is a little hard to explain, but here goes:
"did you remember buying candles for the birthday cake" would be a different question. Here, we want to know whether or not the person remembered that he was supposed to buy some candles, and did he buy them; not whether he remembered the experience of buying them.
"I remembered to buy candles" = "i remembered that I needed to buy candles, and I bought them."
"I remembered buying candles" = "I remembered the experience of buying candles" or "I remembered that I (already) bought candles"
You are right that "remember doing something" where the "doing" happens in the past - but in that case you remember the experience of doing or the fact that you did it. "Remember to do something" means that you remember something that you are supposed to do, and do it. It is a similar usage to "I wanted to do something" or "I tried to do something"
I hope that makes sense!