What happens if the demand curve is flat because the firm is a price-taker in the market, but the firm has a constant marginal cost. If the equations are the same I assume the price would be set with a theoretically infinite quantity, but what happens if they are different?
This is somewhat unrealistic, but so be it...
If $p=MC$, then for each additional unit you get as much as you pay, therefore your profit is constant in quantity, either 0 or negative (because of fixed costs). In the latter case you would exit the market in the long run, but in the short run your profit maximization problem is indeterminate (every quantity is optimal). In the former case your profit maximization problem is indeterminate in the short and in the long run.
If $p<MC$, then you would shut down to minimize your loss.
If $p>MC$, then your profit maximization problem has no solution in the real numbers. (You want to produce an "infinite quantity".)