The two main reasons for ending up with mac and cheese that has a grainy texture are that the ratios from the roux to the fat content may be off or you're overcooking the sauce.