Different locations have different rules. Most of the world requires absolute novelty at the day of application. They have zero grace period. In these counties the rational for absolute novelty is simple. They can believe you are a true originator of an invention if it has not come to light before they open the envelope containing your application.
Once it has been published anyone can claim they were the first. It might have been published under the name John Smith but maybe three John Smiths claim to be the author. Authenticating who mailed in an application to the patent office is under the control of the patent office while authenticating who submitted to a journal is not. They also have a simple rule for deciding who the inventor is - first-to-file, period. This fits well into an absolute novelty system.
In a pure first-to-file system, if you published and I later filed an application I would get the patent. This is avoided by zero grace period - in this scenario no one gets a patent. First-to-file getting the patent and absolute novelty requirements logically go together in a system that reduces arguments as to who is the real inventor.
However, recognizing your point, a few places do have some grace period for time between disclosure and filing. The U.S. is the most significant place by far to have a grace period. Before a change to the law in 2012, there was a clear one year grace period. That is incompatible with first-to-file so we had a complex first-to-conceive system.
The first-to-conceive got the patent as long as from conception to "reduction to practice" they worked diligently on the invention, but it’s way more complicated. Made for good questions about convoluted cases on the patent bar exam.
To settle disputes over who was first to conceive and if work was continuous thereafter there was an "interference" proceeding where inventors brought lab notebooks with signed and dated pages, receipts for parts they bought for prototypes, etc. This complexity to establish true inventorship is required in a grace system.
Now the U.S. is a "first-true-inventor-to-file" system with a quasi one year grace period. Inference proceedings are gone but there is a little used process to try to prove the first application was filed by someone who took the idea from a true inventor.
I initially thought the 2012 change was unfair to the "true inventor" but the reduction in complexity of first-to-file is clear.
Another issue is that inventorship and authorship are two different things. You might have four authors on an academic paper who all made a contribution to the paper but not all made a conceptual contribution to the “invention”. What level of contribution gets you authorship varies between disciplines and countries.
Another aspect of the issue is notice to the public. You publish something but do not file a patent application - can I use it? How long do I wait to find out if you change you mind and decide to protect it? There needs to be some short reasonable limit.
From a practical point of view, an author could put a Provisional Application Cover Sheet on a draft of an article that is about to be published and submit it to the USPTO for a very small filing fee. This establishes you are the originator of the content of that article and is good for one year (it's not the grace period year).