What do researchers mean by the "priority" of an idea? I have heard the term "priority" used in regards to research ideas. For example, How does one determine priority, prominence, and impact with regard to books, rather than articles? asks about priority (and other things) in regards to books.

From the usage I have seen in this community, priority appears to be established when you submit a manuscript (e.g., to a publisher or arXiv). This seems very weird to me, so I am worried that I am missing something. The time at which an idea is submitted for publication can be years after the idea was had, so it seems priority is not giving credit to the first individual who had the idea. Since the review process is confidential and it can take years for an idea to get published, priority is not being given to the person who first disseminated the idea either.

What exactly is priority and why does it matter?
The way I use this term, "priority" means "who had this idea first". Of course, everyone can come up and say "hey, I totally had this idea to determine graph isomorphism in quasipolynomial time in 1990", so it is difficult to validate a priority claim unless there is some written material to back it up. But intellectual priority is the former concept; publication dates are just an imperfect way to measure it.

In fields where research is routinely disseminated before formal publication (using arXiv, preprints, or conferences), such as mathematics, there are (in my opinion) fewer possibilities for issues such as "X had the idea one year before Y, but Y's paper was published earlier" or "Y was a peer reviewer and scooped X's idea".