Personally I would just nail it to the studs. I would be careful & nail it on the edge furthest away from the tank with nails that are just long enough to catch the stud. It's hard to say without knowing how thick the trim u are using is but if it's 3/4" thick then 1 1/2" nails will get u through the trim, drywall & still catch the stud. So if u are nailing it more then 1 1/2" from the tank then even if the nail curls out it still won't hit the tank.
If u are using a small piece of trim & it won't work that way because u have to nail it to close to the tank then u could use liquid nail to hold it & use some really short nails that just catch the drywall to hold it in place until the liquid nail dries.
If u are using 3 1/4" or bigger trim then it really shouldn't be a issue because u should have enough room to nail it. As long as u are using the right sized nails then even if they curl out it shouldn't hit the glass.
If u don't have the room & u have to use adhesive, I would glue it to the Sheetrock & not to the tank. All I would do to the tank is caulk down the edge where the trim & the glass meet after I installed the trim. I would use clear caulk or silicone to fill any gaps where they meet so no water can get between the trim & glass somehow. Clear caulk would work good for that because I would want the bead to be as small as possible & caulk is easier to use then most silicone. Although some silicone is easier to use then others so if u have a brand that u use that is easy to work & also paintable then I would use that.