The Jedi are hypocritical to their code. They form attachment pretty often (Revan, Meetra Surik, Anakin, Satele Shan.... The fact that a 'Shan bloodline' exists is proof of this.)
Plus, the notion of 'Detachment' as people understand it is not the same as 'Non-Attachment', which is what they realistically think the Jedi believe they should follow. Sadly, this is a misnomer: Jedi advocate detachment, meaning to separate oneself from the emotionally-controlling elements of relationships where attachments are present. This doesn't mean that they don't form relationships: they have to. Masters form relationships with Apprentices, they have friends, colleagues, allies and so on - and, obviously, some even had families. Might be easier if I outline the differences between the two:
Detachment
This is a state whereby one removes control-elements from their thinking, so that they can maintain an attachment without it having an effect on their judgment. Think of it like this: you're the parent of a child currently studying at school. Because you want the child to succeed, you place pressure on them to get good grades. When they don't, you become disappointed, and they feel guilty. What has thus resulted is that your child has been pressured by you, feels badly about themselves because they have disappointed
your expectations, and this has meant that your attachment (and theirs to you) has actually harmed them emotionally. This is the control-element in the relationship: the cycle of expectation by one causing disappointment and thus making the other person feel bad/guilty because they didn't meet your expectations.
The idea of Detachment is to remove this element: to be aware, consciously, of the ways in which an attachment to another person (whether a friend, colleague, member of your family...) can potentially affect your judgement, or affect them in ways that might alter your behaviour. It's essentially whereby you liberate yourself (and them) from having their judgement clouded by your influence, or yours by theirs. Use our previous example: if you know that expectation can create disappointment and lead the child to feeling bad about themselves, you can remove expectations from the equation: encourage, but don't judge, so that the child ultimately works hard and tries their best, but doesn't have to worry about hurting your feelings (i.e. by disappointing you!), and thus is able to act free from the burdens their attachment places upon them.
For Jedi, it boils down to a practical approach: they can form relationships, but ultimately separate themselves from these controlling influences. They can respect, admire and love the people they are attached to, but keep themselves aware of these influences, so when the time comes to make a decision, they can separate themselves from them. As Yoda said: "train yourself to let go of everything you fear to lose". That's not saying don't form the attachments, it's saying that you have to learn to detach yourself from the need to hold onto those relationships: that you have to be prepared to let go when the time comes, because you serve the Force and must act for the greater good, not merely for yourself. It's where Anakin screwed up - and also why he ended up killing the woman he loved: because he couldn't let go.
Non-Attachment
This is the more aggressive of the two doctrines: it requires that an individual utterly isolate themselves, by never forming close relationships or attachments to people, organisations and objects, essentially being able to 'let go' at any time, simply because the connections they do form are ultimately transitory. This thus enables them to act in a manner that frees them of attachment conditions: they don't have the burden of worrying what people will think or feel, because those relationships (however tenuous) don't really matter in the long-run. Technically, it's effective (if difficult to achieve), but hard for the majority to adopt, simply because it's natural to form relationships and connections. As such, the idea of Non-Attachment would exist, perhaps, as an ideal, rather than as a practical reality.
Which do the Jedi follow? I'd argue Detachment rather than Non-Attachment - certainly the Jedi of the New Jedi Order used the former, and I'd argue that such was true of the Old Republic Jedi Order as well. It's not about
not forming attachments, but rather about being able to let go of those elements in these relationships which would adversely affect the decision-making of the Jedi in question. If you have people trapped in a burning building: your family in one room, a group of doctors in another, senators in a third, and a small group of children in the fourth, when you can only save but one group before the whole thing collapses, whom do you save? A person constrained by attachment would choose their family: thus, the Doctors, the Senators and the children would die. Is this the right move to make? Or does it mean that more people will die because the Doctors won't be able to save them? Or that worlds will suffer because the Senators are unable to act for their benefit? Or that the lives of many potential families will cease to exist, because the group of children never grow old enough to have children of their own? Which would you go with? View it through your personal attachments, then think independently of them. What's your conclusion?
Anyway, I don't think the Jedi are hypocritical with regards to their policy of Detachment, just for reference. Thought I'd clear up that common misconception before it got people all riled up. It's normal to think that they mean 'form no attachments', but common sense really says otherwise.