Bonjour Leah !
This is an excellent question.
The difference here relates to impersonal expressions.
Here's the rule:
- When you have a real subject, like "première erreur" - i.e. to do. - and that the infinitive is used intransitively (without a object), then the structure is:
[subject/adjective] + à + [infinitive]
La première chose à faire...
The first thing to do...
C'est bon à savoir.
That's good to know.
- When you have a *dummy* subject - i.e. it is to do - the structure is:
il est/c'est + [adjective] + de + [infinitive]
Il est difficile de parler. / C'est difficile de parler.
It's hard to talk.
Il est important de faire confiance à ses amis.
It's important to trust one's friends.
I hope that's helpful!
À bientôt !