Patent offices play a crucial role in preventing infringement by thoroughly examining patent applications to ensure that only novel and non-obvious inventions are granted patents. They also maintain databases of granted patents, which researchers and companies can consult to avoid unintentional infringement. Furthermore, patent offices provide legal frameworks and support for resolving disputes related to intellectual property rights.