I just chulk it up to the environment of the grandline. It's almost impossible to track anyone in there due to its impredictable weather and difficulty to navigate its waters. Besides Luffy was always lucky at avoiding capture by the marines, he had help practically everytime he was seriously cornered.
He escaped Smoker by Dragon's help in Logue town, shielded/hidden by the Nefertary in Alabasta at the end of the arc, Merry Go saved him at Enies Lobby, Garp spared him at Water 7, Spared by Kuma in TB and saved again by him in Sabaody, in Dressrosa Fujitora refused to capture him, etc.
Maybe the WG weren't depicted on panel to be desperate to capture him until recently or at least that's what my memory supplies to me but yeah he was very lucky to escape them till now eventhough they tried multiple times.