Most of it is luck of the draw, and the rest from breed tendencies, how much they've been handled and how consistent and routine you are in your handling. I have birds that I got at 7 weeks old from a feed store lot that are as friendly as birds I've raised since 2-3 days old. I treat the chicks from each batch equally but that yields every sort of behavior from flighty to being constantly underfoot. But even my flightiest bird will still come when called because I'm very consistent with rewarding for it, and she still accept treats from my hand before running off.