Revised Answer:

Heres what I would do if I were you

Trigger

    trigger TestTaskTrigger on Task (before insert) {
           if(trigger.isInsert && trigger.isBefore){
           		Task_Methods.setWhat(trigger.new);
    		}
    }

Class

    public class Task_Methods{
    	public static void setWhat(List<Task> newList){
            List<Task> tList = new List<Task>();
            Map<Id,Contact> contactMap = new Map<Id,Contact>([SELECT Id, AccountId FROM Contact WHERE AccountId != null]);
    
    		for(Task t : newList){
    			t.WhatId = contactMap.get(t.WhoId).AccountId;
    		}
    	}
    }