For the same reason anything else has an attack bonus; because it's making an attack.
An attack (roll) represents something that can be foiled by a creature's Amour Class; the slash of a sword, the flight of an arrow or dart, etc., and it generally requires a creature or object that can be targeted.
On the other hand, a Difficulty Class (DC) is used for ability checks or saving throws and generally represent how hard it is for a character to resist/overcome certain effects.
A save makes the most sense when something bad happens to a character and the character has a chance to avoid that effect. [...] a saving throw is a split-second response to the activity of someone or something else. [...] Other times, a situation arises that clearly calls for a saving throw, especially when a character is subjected to a harmful effect that can't be hedged out by armor or a shield. (DMG pg.238)
Traps that require an attack would have an attack bonus. Traps that inflict a "harmful effect" would have a DC and require a saving throw or ability check.
The Poison Darts trap is a perfect example of both of these cases. The dart itself can be stopped by the target's AC (flavour wise it's dodged, block by armour or shield, or just misses), and the harmful effects of the poison can be resisted if the dart hits.