Don’t book anything. Buy the ticket when you are at the airport station. Air travel is unpredictable. Flights are sometimes delayed by a multiplicity of factors (like weather) so you don’t know if your flight will arrive on time. Immigration procedures are not the issue.
Trains don’t run out of seats, and the full fare (called BASE fare) does not increase between now and your time of travel, so you have no reason to book ahead. Of course booking well ahead of time might give you a chance of getting a discounted fare. But discounted fares have restrictions and if your flight is late you can’t get reimbursed so you lose it all. The highest discount you can get to Venice is about 25€ savings per person. If that savings is worth the risk to lose it all for you, then give yourself at least 4-5 hours buffer between landing and the departure from Centrale. From the time of landing to the time you are at the Milano Centrale station you can expect to take two hours at the very least, one of which is the train ride, and the rest is deplaning, immigration, baggage claim, the long walk from the airplane door all the way to the station, and the wait for the next train (there is one every 30 min to Centrale). I never pre-purchase when I take the train after landing. I just pay full price whenever I get to the station (in my case it’s usually the train from Rome airport to Florence).