I don't find "retain" idiomatic in this context. The use of the words is consistent with imagining "attention" as something you hold up, like a flag in your hand.
"Retain" means "keep", or "keep hold of", but has no implication of keeping the object in use, or holding it up, merely continuing to possess it: it might be in a store, for example. I can imagine it being used of the thing the person is focussing their attention on: Novels can't retain my attention, but not of the person attending.
"Sustain" means "keep something going" or "hold something up", and fits well with the metaphor.