What can I do to prevent this in the future?
If you are on a personal connection, like in the house, you can run an anti-virus scan on your device to make certain it is not contaminated with malware.
If you are at an office or shared network, you can ask the network administrator to run a scan across the network trying to find misconfigured or infected gadgets.
Another method to prevent getting this page in the future is to utilize Privacy Pass. You may need to download version 2.0 now from the Firefox Add-ons Shop.