Is “Can’t be too careful” an idiom?
Solution 1:
Yes, "can't be too careful" is an idiomatic phrase, a shortened version of "you can't be too careful."
The phrase simply means that one shouldn't take (unnecessary) risks, that one needs to be watchful, prepared, or prudent:
you can't be too careful: used for saying that it is important not to take risks
You can’t be too careful when it comes to taking financial advice.
(Macmillan Dictionary)
The implied subject, as AllInOne's answer correctly says, is you. It's a generic you.
Solution 2:
"Can't be too careful" is a set phrase of very long standing in English and has the meaning "it is impossible [for one] to take too many precautions" or "it is impossible [for one] to take something into consideration too much."
One of the earliest Google Books matches for the phrase appears in a speech by the Lord Keeper in the House of Lords from February 21, 1623, reproduced in Journal of the House of Lords, volume 3 (1620–1628):
His Majesty's Resolution is, the Son of the Bond-woman shall never inherit with the Son of the Free-woman. His Royal Majesty hath given Leave to us that are his Chaplains, to put Him in Mind of this. God is ever careful of Kings, and Kings cannot be too careful of him.
Another very early instance is from Francis Beaumont & John Fletcher, The Coxcomb (circa 1608–1610):
Antonio. There she shall stand for me; you are Ignorant, this is a common custom of the Rogues that lie about the loose Parts of the City.
Mercury. As how?
Antonio. To knock at Doors in dead time of Night, and use some feigned Voice to raise Compassion, and when the Doors are open, in they rush, and cut the Throats of all, and take the Booty; we cannot be too careful.
In the OP's example, the generalized "you"—or "one"—is the implied subject; but the sense of the sentence is "I [Hagrid] can't be too careful."