Offices and creativity are at odds because creativity can’t be scheduled, and it’s likely that at some point, people will be in a situation where they are in the office in a creative lull.
It should be totally fine to take a break, or even leave the office (go home) if the creativity is missing. Taking a break is better than excess context switching.
This is unfortunately difficult in some working environments:
In synchronous (in-office or remote) working environments, software engineers are generally expected to be present for upcoming meetings, and are expected to be readily available for collaboration (e.g. pair programming).
In some synchronous (primarily in-office) working environments, taking a break or even not producing visible results is considered taboo. For example, a coworker once commented on me being lost in thought, saying “uh, shouldn’t you be typing?”
Some working environments (in-office) have fixed working hours, which for any creative profession does not make sense and will yield inferior results. Asynchronous working environments make it easier to divide up time than synchronous working environments, but even those are still better than fixed-working-hours environments.
You are not paid to be busy. You are paid to produce results, or to increase the result output of the team/department.