U.S. government works are not eligible for copyright.
Some works do not have sufficient creative element to be covered by copyright, or the other user may be using only the non-covered elements of the work (factual collections, or see recipes).
But probably most important, fair use is a limitation to the exclusive rights of copyright, in spite of copyright holders' frequent assertions that "any other use without written consent is prohibited". A use may be fair even against the express wishes of a valid copyright holder, as fair use is not infringement. Factors to be evaluated in fair use include, but are limited to:
(1)the purpose and character of the use, including whether such use is of a commercial nature or is for nonprofit educational purposes;
(2)the nature of the copyrighted work;
(3)the amount and substantiality of the portion used in relation to the copyrighted work as a whole; and
(4)the effect of the use upon the potential market for or value of the copyrighted work.
https://www.copyright.gov/fair-use/https://www.law.cornell.edu/uscode/text/17/107 see 107-112 for other limitations of copyright.
A license notice provides a clear explanation of the rights and responsibilities of the user. This dissuades most any notion of "lack of intent" as the restrictions are put in your face from the start.
I have a bunch of code in a repository or set of repositories. I got confused and thought this file was one we created/had a license to reuse rather than a piece of third-party code, and thus copied it into a different project.