There is no “right” answer to this question. It comes down to preference and the limitations of the exact space you are working on. In general, it is typical to set cabinets flush with the wall, but not necessarily in all cases. Some people will set their bottom cabinets off the wall to allow the counter space to extend another few inches in a small kitchen. Generally, you want your upper cabinets flush with the wall, but again people will choose otherwise in certain circumstances.
For example, if the ceiling is textured in a remodel, they may offset the cabinets to cover up the existing difference. Or to feature them more prominently for display purposes. Or in cases where the walls are not true (perfectly level), they may keep the cabinets off the wall to keep them level. In short, you’ll want to consider what will look best for your kitchen rather than assume flush with the wall is necessarily the best answer.