The fixed-price contract is generally used when the scope of the project is clearly defined. The T&M contract is generally used when the scope of the project can't be clearly defined (a customer can't provide a detailed scope of work, requirements change frequently, etc).
But what contract type do we use when a customer is able to define scope and specifications to a great extent, bot nevertheless not completely - there're still some questions that can't be answered right now, there're some potential flaws in the overall design of the product, etc.