The Yankees were trying to improve their rotation when they doubled down on what already was an area of strength, righty power, by obtaining Giancarlo Stanton.

If anything, their need for a starter only has grown greater and so has their righty power, with rookies Miguel Andujar and Gleyber Torres already having combined for 27 homers.

Yet, the Yankees have at minimum sat down at the poker table for Manny Machado for the same reasons they initially inquired on Stanton: 1. They are the Yankees and they check on everything, especially the big stuff. 2. They sensed the market was such that the price could fall to “Godfather” levels — an offer they can’t refuse. 3. You can’t acquire a high-end starter if that ilk never becomes available and/or the sticker price is evaluated as too exorbitant. 4. There are two ways to improve a team, and if you can’t find the piece to help you give up less, then look into areas to try to score more.

Remember the sequence that led to Stanton wearing pinstripes. The Yankees were focused on Shohei Ohtani and then were never really in the game, failing to make his final-seven list. Ohtani was not only a top-of-the-rotation possibility, but was going to get a piece of the DH job. With that DH possibility gone, the Yankees pivoted to Stanton.

Brian Cashman told The Post on Tuesday that his priority remains finding a starter and that he sees what the Yanks have at third base now as a strength, not a weakness. But an elite starter may never become available. And if one does, with Jacob deGrom or Noah Syndergaard, the Yankees would be never really in the game — like with Ohtani — because the chances of the New York teams agreeing on a trade of this magnitude are minuscule.

Stanton, though, had a no-trade clause, which he invoked to prevent deals to San Francisco and St. Louis. He was amenable to the Yankees, Astros, Cubs and Dodgers. That, combined with 10 years left on the largest contract in MLB history, reduced the Marlins’ prospect request to a level the Yankees found tolerable.

Kevin GausmanAP

Machado does not have no-trade protection and is owed about $7 million on his $16 million 2018 salary (which will go down each day leading to the deadline). Even the Yankees and Dodgers, counting every penny to stay under the $197 million threshold, could shoehorn Machado into their payroll. The Yankees currently project to about $181 million, the Dodgers $184 million.

The Dodgers, Diamondbacks, Brewers, Indians and Phillies are known to have interest, with Arizona and Milwaukee viewed as the current favorites. The Diamondbacks have a narrow window to go for it now with A.J. Pollock and Patrick Corbin free agents after this season and Paul Goldschmidt after next, plus the Dodgers in that penny-counting mode in 2018, but not in 2019. Plus, Arizona saw the value of obtaining the best walk-year hitter on the market last season with J.D. Martinez powering its wild-card run.

The Brewers saw the same impact in 2008 by obtaining the best walk-year starter in CC Sabathia and making the playoffs for the first time since 1982. Owner Mark Attanasio has that institutional memory and also has a team with the NL’s best record, but a black hole at shortstop.

Because of the competition for such a talented player, the Orioles can expect to get better than the middling package the Tigers received last July for Martinez. But because of the walk-year status, the haul won’t be as great as Machado’s name would suggest.

But a suitor might be more agreeable to give up an elite package if another piece were mixed in. Pretty much every interested team, including the Yankees, also would be attracted to walk-year closer Zach Britton or players with more control, such as setup man Mychal Givens or starters Dylan Bundy or Kevin Gausman.

The addition of, say, Gausman with Machado also would give the Yankees a talented but underachieving starter to try to weather this season. Or Britton could help further shorten games with the Yanks’ brilliant pen.

The key piece, though, would be Machado, who defiantly said after Monday’s doubleheader that he is a shortstop. But if traded, he would have no control, and stars such as Alex Rodriguez and Stanton have switched positions to play for the Yankees.

Machado was a brilliant defensive third baseman. Andujar, who likely would have to go to the minors or to first base or be part of a deal, is not. In addition, Machado delivers homers, but has among the lowest strikeout rates in the majors, which would benefit this Yankees lineup. He also has particularly strong numbers against Chris Sale, David Price, Rick Porcello and Drew Pomeranz, which is significant since the Yankees have nine post-July 31 games against the Red Sox as the two battle for the AL East title.

That Machado is having his best offensive season in his walk year would suggest he could handle the pennant race/New York pressure. Machado, though, is playing the more demanding shortstop this year and has had major surgery on both knees, so an acquiring team would have to be concerned about whether he will wear down late this season.

Will the Yanks be that acquiring team? The Orioles might be trumpeting the Yankees’ interest to intensify bidding. But keep in mind that when the Yanks were first mentioned with Stanton, it also felt like a pipe dream.