Your dog may get fleas from another flea-infested animal - a stray dog or stray cat, or even various other neighbors' cat or dog, or even from other wildlife animals like opossums and raccoons - traveled through your area, your lawn, along with the flea is putting eggs. The eggs are mostly rained off to your surroundings. We call them a salt shaker that is dwelling. And those eggs grown into adults and also these fleas jumped onto your pet. That is how it occurred.
Dogs generally get ticks since they are out in that environment, walking through the woods or higher grass, and such ticks undergo what is called questing, where they creep up on those low shrubs or grass, generally 18 to 24 inches away from the floor and they hang out. And we walk and brush up against those ticks or when the dog walks by they get and dislodge onto us. Ticks do not grow up into trees. That is an old myth. It is sort of a strategy. They can live without feeding.
There are lots of highly effective Spot-on Treatments, Oral Medications & Tick Collars for control ticks on your dog such as Frontline Plus, Bravecto, Seresto Tick Collar, Revolution, etc.