When discussing a firm, economists generally assume that the firm wants to maximize profits — in other words, that the difference between total revenue and total costs is positive and as large as possible. Economists don't think there's anything immoral about profit maximization. Rather, they believe that profit maximization is a goal that helps a firm be efficient, and firms that don't make profits tend not to operate as firms for very long.
Of course, some nuances apply to this view of profit. For one, the existence of profits in the economist's sense says nothing about how those profits may be distributed. For example, an LLC may want to retain some profits for future investment and return some to shareholders as dividends. But although a nonprofit company still intends to make a surplus (as it would be called in the accounts, reflecting the different legal as opposed to economic definition of the company), it does different things with that surplus, which may include distribution to workers or to chosen worthy causes.
But beyond this consideration, other reasons may exist why a firm may not be acting as a profit maximizer:
Tax systems where company taxes fall on profits can provide an incentive to declare lower levels of profit.
Managers may have different incentives than shareholders and prefer to generate higher salaries for themselves than higher profits for the company (managers' wages here would be a cost to the company).
A company may prefer to evaluate its performance using some other measure, such as sales or market share, at least in the short run. Some examples include companies in online markets where interim measures commonly used include market share or number of users.
Is this a problem for microeconomists? Not necessarily. In most situations, they want to make a simplification that helps them understand the world instead of covering every possible case. So, when considering different types of markets the benchmark of the profit-maximizing firm helps economists consider how they may be similar or different.
Economists also want to compare their models to real-world situations. In order to do that, they can start from a simple assumption and then, as things become more complicated, refine it in the light of real-world events.