Can cooking food longer and at a higher temperature prevent gastroenteritis?

Not the common types. These are mostly spread by dirty hands. Overcooking and boiling drinking water can prevent some foodborne infections such as e coli or listeria, though.
Sometimes. But not always. Some kinds of food poisonings are heat resistant so it would not matter. Good thought though !
Some. Undercooked animal products (runny eggs, undercooked poultry, rare burgers, etc.)can spread certain bacterial food "poisoning". Cross contamination of cutting boards, with e.g. Raw meat, and then other materials can spread disease. Wash hands. Rare steak ok (germs on outside get cooked, meat inside is sterile); rare burgers: can't tell what came from where. Less the cooking temp, more the meat's.