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?