There's a strong case for not going very far in trying to guess what might be needed in future.
Obviously, the truly "foreseeable" should be catered for now, but the issue with YAGNI is that a programmer might start trying to pre-empt a large variety of design contingencies before it has become clear whether any of these contingencies will actually apply.
Another mistake is to front-load too much design work, rather than adopting a reasonable phased approach. If you try and pre-empt too much design work, even if it is ultimately required, it's possible to simply become overwhelmed with managing all the complexity, such that you don't actually save yourself any work but instead overwhelm yourself with the task.
This isn't a suggestion to be short-sighted, but to distinguish between knowing future requirements and only guessing at the possibilities, and between making sensible preparations for the near future and exhausting your mental energy on the far future when you should be tackling the priorities.
As for "maintenance", there isn't usually a huge tension between code that is correct today and code that is maintainable in the future.
A procedural solution which is already correct and well-structured, is probably not made more maintainable by introducing what is often regarded as an OOP style.
A lot of developers, when they worry about maintenance, are either worried that the code isn't sound to begin with because they haven't fully got to grips with the complexity, or they are satisfied that it is sound but are worried about trying to remember all the details of the design in 6 months time.
The solution to unsound code is to spend more time on it, but the solution to remembering it 6 months later is often a more complicated issue that has no general solution besides adding more manpower and greater specialisation.