。
She signed a contract to write a book.
Literal
She [topic-は] book [object-を] writing [object-を] contracted.
こと nominalizes the clause 本を書く into a noun phrase serving as the object of 契約する. The double を (本を...ことを) is grammatical because they belong to different clauses. Slightly stiff — a native speaker might prefer 執筆契約をした.