Apparently the police did not believe that the other car caused the accident or felt that even if a person did swerve into your lane the accident was avoidable. Unfortunately we have no opportunity to review any police report or to ask them why they issued you the ticket.
You can contest the ticket and try to convince the court that the accident was caused by the third vehicle (this type of vehicle is sometimes referred to as a "phantom vehicle"; yes, that label suggests some skepticism.)

