The IRS makes it pretty clear here. You can only deduct prior year contributions made before the tax return due date (with extensions).
The legal authority is the IRC Sec. 404(a)(6):
(6) Time when contributions deemed made
For purposes of paragraphs (1), (2), and (3), a taxpayer shall be deemed to have made a payment on the last day of the preceding taxable year if the payment is on account of such taxable year and is made not later than the time prescribed by law for filing the return for such taxable year (including extensions thereof).
Also see this (IRC Sec. 404(a)(8)(C) for self-employed individuals):
(C) the contributions to such plan on behalf of an individual who is an employee within the meaning of section 401(c)(1) shall be considered to satisfy the conditions of section 162 or 212 to the extent that such contributions do not exceed the earned income of such individual (determined without regard to the deductions allowed by this section) derived from the trade or business with respect to which such plan is established, and to the extent that such contributions are not allocable (determined in accordance with regulations prescribed by the Secretary) to the purchase of life, accident, health, or other insurance; and
The timing for adoption of the plan is governed by the IRC Sec 401(b)(2):
If an employer adopts a stock bonus, pension, profit-sharing, or annuity plan after the close of a taxable year but before the time prescribed by law for filing the return of the employer for the taxable year (including extensions thereof),
This part was amended by the Secure 2.0 act, as enacted (see PL 117-328):
(a) In General.--Section 401(b)(2) is amended by adding at the end
the following: ``In the case of an individual who owns the entire
interest in an unincorporated trade or business, and who is the only
employee of such trade or business, any elective deferrals (as defined
in section 402(g)(3)) under a qualified cash or deferred arrangement to
which the preceding sentence applies, which are made by such individual
before the time for filing the return of such individual for the taxable
year (determined without regard to any extensions) ending after or with
the end of the plan's first plan year, shall be treated as having been
made before the end of such first plan year.''.
(b) <<NOTE: 26 USC 401 note.>> Effective Date.--The amendment made
by this section shall apply to plan years beginning after the date of
the enactment of this Act.
This is for unincorporated self-employed individuals (disregarded SMLLC or sole proprietors). This is the part you're referring to.