Correct to prepare or for preparing?

Both are correct in different circumstances: To prepare a meal, you must have the proper ingredients. He got in trouble for preparing a meal in his bedroom.