Like cancers, nothing you do can "guarantee" you won't get it, as even the healthiest and most active people can still get dementia, as they can still get cancer. But it's all about probabilities etc. The more you can do to have a healthy, active lifestyle and keep your brain active, the better - it will improve your probability of not getting dementia.
My MIL has it - she ate healthily, but wasn't social, didn't do any exercise and didn't keep her brain active. Literally, all she did all day was read the Daily Mail (I kid you not!), she didn't even do the quiz/puzzle page, and then she'd sit and watch TV, she never read books. She'd not leave the house for days, only to go out once a week to do the shopping and pay her paper bill! She wasn't depressed, that was her life and she was happy with it - just very reclusive.
My DM was the opposite, she was still doing line dancing at the age of 85, was the secretary of a local AmDram group until around 80, still working in the family business until she was around 75, had a dog so out walking 3 times per day, walked to the library every 2 or 3 days to pick up new books to read. Brain constantly on the go, constantly watching TV news and documentaries, etc. It was her body that let her down, not her mind, her brain was as sharp as ever right until the end.
All you can do it put yourself in the best possible position through keeping the brain active, keeping social, keeping physically active, keeping fit and healthy, and yes, hearing aids at the first sign of hearing loss. Trust research and facts rather than anecdotes.