They were both the bloodiest battles America had seen at their respective times and both were union victories. However, when the public heard of the victory at Shiloh they were shocked and appalled at the casualties. General Grant was even removed from command for a while as a result of the battle. While, the public celebrated the victory at Gettysburg despite there being nearly twice as many casualties at Gettysburg. This despite the fact the battles where fought almost within a year of each other.
There were a couple factors at play, but I'll try to keep this answer streamlined to three factors. (1) Broad timing and momentum, (2) campaign objectives, and (3) press reactions to the events.
We'll start with Shiloh. In early-April 1862, although Grant had some momentum in the western theatre, things had been stalled until very recently in the east. McClellan had only just finally got his army on the move, and had just begun the siege of Yorktown (April 5) the same day that Johnston and Beauregard were preparing their attack (launched the next day, on the 6th). I bring this up because with Grant's recent victories at Ft. Henry and Donelson, and the excitement surrounding McClellan's grand flanking maneuver, there was serious hype around the Union effort at this time. It really did seem like the Confederacy was about to fold from both ends at once.
Thus, the shock of a seeming reversal on both fronts cannot be overstated. Although Grant's ultimate victory at Shiloh was just that, his contentious relationship with Gen. Halleck in Washington (who framed the victory as borderline pyrrhic) as well as the press (more on this in a bit), framed the battle in a negative light. Although McClellan wouldn't get driven out of the peninsula for a few more months, his slow progress and the alleged disaster out west made for a real morale speedbump for the Union.
On the flip-side, the timing for Gettysburg and the rout of Lee at the end of the battle's third day couldn't have come at a better time for the Union. On July 4th, 1863, Grant negotiated the surrender of Vicksburg, a MAJOR victory for the Union coming just one day after the clear-cut victory in Pennsylvania. Yes, casualties were high for the Union (higher than Shiloh, even), but that was after 3 days instead of two, and the Confederate losses were heavier (which was not the case at Shiloh).
So to that first point, to sum up, the victory at Gettysburg came at a time when the tide had unquestionably turned in favor of the Union. In April 1862 the Union effort seemed stalled; in July 1863, the Union seemed to finally have some momentum.
To point #2: campaign objectives. Grant's campaign (under Halleck) in early 1862 was clicking along wonderfully, and meeting the broader objectives of using the Tennessee river as a hinge or axis for the army's movement. He'd forced Johnston back to Corinth to regroup, and was just about to link up with Buell to run the remaining opposition out of the area more or less unopposed.
Although Grant was keen to press his advantage after the Battle of Shiloh, Halleck overruled him, and the campaign that had been going so well up to that point effectively stalled out. This, combined with McClellan's failure on the peninsula in the east, represented a stalemate on both fronts for the Union (again, at a time when it seemed like they were primed for a knockout punch to end the war).
In sports terms, it's like going up 3-0 in a series, then dropping three games in a row to even it up at 3-3. Which brings us to our 3rd point: the press. I've written in the past about Grant's contentious relationship with newspaper reporters (see here: https://www.reddit.com/r/AskHistorians/comments/ojvwm4/i_just_found_out_about_ulysses_s_grants_general/), and it did him no favors after the Battle of Shiloh. Most of the newspaper coverage somewhat understandably focused on the shocking casualty figures and not the outcome, which was that a major Confederate army had been defeated, its commanding general killed, and its soldiers driven from the field. The New York Times, for example, published an article on May 18th, 1862 (https://www.nytimes.com/1862/05/18/archives/the-loss-in-the-battle-of-shiloh.html) that dealt almost entirely with the casualties and little else. Compare that to the headlines that spoke about Gettysburg, like the Lancaster Intelligencer from Jul 7, 1863, whose headline reads, "The Rebel Army Defeated and Driven Back" (https://lancasteronline.com/news/battle-of-gettysburg-read-1863-newspaper-coverage-from-lancaster/article_99a5e2bc-94bb-5383-897e-95694a5b5d7b.html). This is running a touch long, so forgive me for not providing more examples to illustrate, but long story short, the press treated the battles and their outcomes much differently, which did sway public opinion in both cases. Whereas Shiloh represented a terrible tragedy by way of staggering casualty figures not seen before on the continent, Gettysburg acted as part of a one-two punch combo whose equally appalling casualties had become somewhat (tragically) expected by that point.
[Sources: Bruce Catton, 'Grant Moves South'; Stephen W. Sears, 'Gettysburg'; Doris Kearns Goodwin, 'Team of Rivals']