Why does the same algorithm give very different metrics on similar datasets?
Simple answer: the datasets are different. Apparently, your approach worked well for A but not for B. From this you might infer, that B and A are not so similar after all. I suspect that B has a more complicated relation between the X and targets y. So maybe try boosting on B?!