will get the RectTransform of ANY child, not necessarily the panel you want. if you know the name of the panel then search for it by name
var panel = GameObject.Find("PanelNameHere");
if (panel != null) // make sure you actually found it!
{
GameObject a = (GameObject)Instantiate(b);
a.transform.SetParent(panel.transform, false);
}
Actually I believe what is happening is GetComponentInChildren does not function exactly how you would think. It starts with itself and looks for RectTransforms there, so you are in fact finding the RectTransform of the canvas not the RectTransform of the Panel.
I know this seems backwards and have wondered why unity does this, but the object looking for components in child seems to include itself in that search, go figure.
If you did GetComponentsInChildren and took the second element in the array [1], this should be your Panels rectTransform